package com.smartcampus.demo.controller;


import com.smartcampus.demo.domain.Temperature;
import com.smartcampus.demo.service.TemperatureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("api/temperature")
public class TemperatureController {

    @Autowired
    private TemperatureService temperatureService;

    @GetMapping
    public List<Temperature> getAllTemperature() {
        return temperatureService.getAllTemperature();
    }

    @GetMapping("/{id}")
    public Temperature getTemperatureById(@PathVariable Long id) {
        return temperatureService.getTemperatureById(id);
    }

    @GetMapping("/latest/{n}")
    public List<Temperature> getLatestTemperature(@PathVariable int n) {
        return temperatureService.getLatestNTemperature(n);
    }
}
